package com.geniusk.system.service.impl;

import com.geniusk.system.model.mapper.UserMapper;
import com.geniusk.system.model.pojo.User;
import com.geniusk.security.annotation.PreDataAuth;
import com.geniusk.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User selectUserByUserName(String username) {
        return userMapper.selectUserByUsername(username);
    }

    @Override
    public boolean selectUsernameIsExist(String username) {
        return userMapper.selectUsernameIsExist(username);
    }

    @Override
    public int registerUser(User user) {
        return userMapper.registerUser(user);
    }

    @Override
    public User selectUserById(Long userId) {
        return userMapper.selectUserById(userId);
    }

    @Override
    public User selectUserByMobile(String mobile) {
        return userMapper.selectUserByMobile(mobile);
    }

    @Override
    @PreDataAuth(groupAlias = "g", userAlias = "u")
    public List<User> selectUserByPage(User user) {
        return userMapper.selectUserByPage(user);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int updateProfile(User user) {
        return userMapper.updateProfile(user);
    }

    @Override
    public int deleteUserByIds(Long[] ids) {
        return userMapper.deleteUserByIds(ids);
    }

    @Override
    public int updatePassword(User user) {
        return userMapper.updatePassword(user);
    }

    @Override
    public int updateAvatar(Long username, String avatarUrl) {
        return userMapper.updateAvatar(username, avatarUrl);
    }

}
